<%-- 
    Document   : w_customer
    Created on : Sep 22, 2013, 3:11:55 PM
    Author     : Trang
--%>

<%@page import="model.Role"%>
<%@page import="model.Staff"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="http://displaytag.sf.net" prefix="display" %>
<!DOCTYPE html>
<%
    Staff staff = (Staff) session.getAttribute("staff");

    if (staff == null) {
        response.sendRedirect(request.getContextPath() + "/Administration");
        }
    else {
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Customer Management</title>
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

        <link href="<%= request.getContextPath()%>/css/style_for_page.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_for_menu.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_addtion.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_for_warehousing.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/adMenu.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/tHeaderFooter.css" rel="stylesheet" type="text/css"/>
    </head>
    <script>
        function myFunction()
        {
            var x;
            var r = alert("You cannot delete this item.");
        }
    </script>
    <body style="background-color: lightsteelblue;">
        <% int i = 0;%>
        <div class="headerbg">
            <div class="header"> 
                <%@include file="/include/mHeader.jsp" %>
            </div>
            <div class="adContent">
                <div class="adMenu">
                    <%@include file="/include/mMenu.jsp" %>
                </div>
            </div>
        </div>
     
        <div class="contentbg">
            <div class="content">
                <div style="width: 1024px; color: white; background-color: #610B0B; float:left;margin:auto;">
                    <h3 style="margin-left: 10px;">Customer Information</h3>
                </div>
                <div id="errorMessage" style="border-bottom: 1px #610B0B dashed; ">
                    <div id="sl12">
                        <img src="<%= request.getContextPath()%>/css/create.png" style="height: 40px; width: 40px;"/>
                    </div>
                    <s:form cssStyle="float:left" action="sort-customer" namespace="/Administration/Customer" theme="simple">
                        <div id="sl12">
                            <p style="margin-left: -12px;"><b>Sort by: </b><s:select name="sort" cssStyle="width: 200px" list="sorts" /></p>
                        </div>     
                        <div id="sl12">
                            <s:submit  value="Sort" cssStyle="width: 100px; background-color: gray;" theme="simple" title="Sort Customer"/> 
                        </div>
                    </s:form> 
                    <div id="sl12">
                        <s:form namespace="/Administration/Customer" action="add-customer">
                            <s:submit value="New Customer"  cssStyle="width: 100px; margin-left: 12px;background-color: gray;" theme="simple" title="New Customer"/>
                        </s:form>
                    </div>
                </div>
                <%
                   Integer customer = (Integer) session.getAttribute("customer");

                   if (customer == 1) {   
                %>
                <div class="content2"> 
                    <div class ="datagrid2">
                        <display:table style="margin-left:10px;" id="simpletable" export = "true" name="customers" pagesize="8" requestURI="customer-management">    
                        <%i++;%>
                        <display:column title="No" media="html" group="1" >
                            <p><%out.print(i);%></p>
                        </display:column>          
                        <display:column property="firstName" title="First Name" sortable="true"/>         
                        <display:column property="lastName" title="Last Name" sortable="true" />
                        <display:column property="address" title="Address" maxWords="5" sortable="true"/>
                        <display:column property="dob" title="DOB"  sortable="true" />
                        <display:column property="email" title="Email" sortable="true" /> 
                        <display:column media="html">
                            <a href="<%= request.getContextPath()%>/Administration/Product/edit-product/<s:property value='idProduct'/>" title="<s:property value='description'/>">
                                <img src="<%= request.getContextPath()%>/image/Edit.gif" style="" alt="edit product" width="20" height="auto" title="Eidt Product"/>
                            </display:column> 
                            <display:column media="html">
                                <s:form id="deleteProduct" action="delete-product/%{idProduct}" namespace="/Administration/Product">     
                                </s:form>
                                <img onclick="myFunction()" src="<%= request.getContextPath()%>/image/Delete.gif" style="" alt="delete product" width="20" height="auto" title="Delete Product"/>  
                            </display:column>
                        </display:table>
                    </div>
                </div>
                <% } 
                 else 
                    //if (customer == 2)
                {
                %>
                <div class="content2">    
                    <div class ="datagrid2">
                    <display:table id="data" export = "true" name="customers" pagesize="8" requestURI="customer-management">    
                        <%i++;%>
                        <display:column title="No" media="html" group="1" >
                            <p><%out.print(i);%></p>
                        </display:column>          
                        <display:column property="firstName" title="First Name" sortable="true"/>         
                        <display:column property="lastName" title="Last Name" sortable="true" />
                        <display:column property="address" title="Address" sortable="true"/>
                        <display:column property="dob" title="DOB" maxWords="10" sortable="true" />
                        <display:column property="email" title="Email" sortable="true" /> 
                        <display:column media="html">
                            <a href="<%= request.getContextPath()%>/Administration/Cusrtomer/edit-customer/<s:property value='idProduct'/>" title="<s:property value='description'/>">
                                <img src="<%= request.getContextPath()%>/image/Edit.gif" alt="edit product" width="20" height="auto" title="Eidt Product"/>
                            </display:column> 
                            <display:column media="html">
                                <img onclick="myFunction();" src="<%= request.getContextPath()%>/image/Delete.gif" alt="delete product" width="20" height="auto" title="Delete Customer"/>  
                            </display:column>
                        </display:table>
                    </div>
                </div>
                <%}
                %>
        </div>
        </div>
        <footer>
            <div id="footer">
                <%@include file="/include/iFooter.jsp" %>
            </div>    
        </footer>
    </body>
</html>
<%
    }
%>